package com.ruoyi.back.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.AppVersionInfo
import com.ruoyi.back.service.AppVersionInfoService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/system/appVersionInfo")
@Api(tags = ["系统设置-关于我们-版本管理"])
class AppVersionInfoController {

    @Autowired
    private lateinit var appVersionInfoService: AppVersionInfoService


    @ApiOperation("保存app 版本信息")
    @PostMapping("save")
    fun saveAppVersion(@RequestBody appVersionInfo: AppVersionInfo): Data<Boolean> = appVersionInfoService.saveAppVersion(appVersionInfo)

    @ApiOperation("app 版本分页")
    @GetMapping("list")
    fun appVersionPage(appVersionInfo: AppVersionInfo): PageData<AppVersionInfo> = appVersionInfoService.appVersionPage(appVersionInfo).pageInfo()

    @ApiOperation("移除app 版本")
    @ApiImplicitParams(
        ApiImplicitParam(name = "versionIds", value = "版本id 多个使用逗号", type = "path", required = true)
    )
    @PostMapping("remove/{versionIds}")
    fun removeAppVersionInfo(@PathVariable versionIds: String): Data<Boolean> = appVersionInfoService.removeAppVersionInfo(versionIds)
}